import axios from 'axios'// 跨域请求

// 创建axios实例
const service = axios.create({
  baseURL: process.env.BASE_API, // api的base_url
  timeout: 1000000, // 请求超时时间
  withCredentials: true// 默认的
})

// request拦截器
service.interceptors.request.use(config => {
//   console.log('request.js_config:')
//   console.log(config)
  return config
}, error => {
  console.log('request.js_error:')
  console.log(error)
  Promise.reject(error)
})

// respone拦截器
service.interceptors.response.use(
  respone => {
    // console.log('request.js_respone:')
    return respone.data
  },
  error => {
    console.log('request.js_error1:' + error)
  })

export default service
